home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / ZISUBCD.CPP < prev    next >
C/C++ Source or Header  |  1993-08-09  |  4KB  |  110 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    zn.cpp
  5. //   Title:    Zinc Window Template
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains code for the class ZI_SUBSCRIBE.
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        OS/2 2.X+
  31. //        OS/2 2.0 PM
  32. //
  33. //    The following compilers are supported:
  34. //        MSC 6.0A
  35. //        MSC/C++ 7.0
  36. //        Borland C++ 3.1 for DOS
  37. //        Borland C++ 1.0 for OS/2 2.X
  38. //
  39. //----------------------------------------------------------------------------
  40. #include <zi.hpp>
  41.  
  42.  
  43. //----------------------------------------------------------------------------
  44. //    Globals
  45. //----------------------------------------------------------------------------
  46. static PCSZ apszSuffix[MAX_SUBSCRIBE_LEVEL] = { "-5", "-10", "-15", "-20" };
  47. static PCSZ pcszKey = "9-Digit ZIP Disc";
  48.  
  49.  
  50. //----------------------------------------------------------------------------
  51. //   Description:    Generate a code for renewing the subscription.
  52. //    Parameters:
  53. //       Returns:
  54. //----------------------------------------------------------------------------
  55. VOID FN_E SubscribeGenerate(SHORT sLevel, PSZ psz)
  56. {
  57.     QueryGenerate(psz);
  58.     Assert(sLevel >= 0 && sLevel <= MAX_SUBSCRIBE_LEVEL);
  59.     strcat(psz, apszSuffix[sLevel]);
  60.     return ;
  61. }
  62.  
  63.  
  64. //----------------------------------------------------------------------------
  65. //   Description:    Generate a response for renewing the subscription.
  66. //    Parameters:    
  67. //       Returns:    TRUE if successful.
  68. //----------------------------------------------------------------------------
  69. BOOL FN_E SubscribeResponse(PCSZ pcszCode, PSZ pszResponse)
  70. {
  71.     Assert(strlen(pcszCode) >= 8);
  72.     for (SIZET i = 0; i < MAX_SUBSCRIBE_LEVEL; ++i)
  73.         if (strcmp(pcszCode + 8, apszSuffix[i]) == 0)
  74.             break;
  75.  
  76.     if (i >= MAX_SUBSCRIBE_LEVEL)
  77.         {
  78.         Error("Invalid inquiry code.");
  79.         return FALSE;
  80.         }
  81.     strcpy(pszResponse, pcszCode);
  82.     pszResponse[8] = '\0';
  83.     QueryResponse(pszResponse, pcszKey);
  84.     strcat(pszResponse, apszSuffix[i]);
  85.     return TRUE;
  86. }
  87.  
  88.  
  89. //----------------------------------------------------------------------------
  90. //   Description:    Generate a response for renewing the subscription.
  91. //    Parameters:    
  92. //       Returns:    TRUE if successful.
  93. //----------------------------------------------------------------------------
  94. BOOL FN_E SubscribeVerify(PCSZ pcszInput, PCSZ pcszResponse)
  95. {
  96.     CHAR szResponse[20];
  97.     CHAR szInput[20];
  98.  
  99.     strcpy(szResponse, pcszResponse);
  100.     strcpy(szInput, pcszInput);
  101.     if (strcmp(szInput + 8, szResponse + 8) != 0)
  102.         return FALSE;
  103.     szResponse[8] = '\0';
  104.     szInput[8] = '\0';
  105.     return QueryVerify(szInput, szResponse, pcszKey);
  106. }
  107. //----------------------------------------------------------------------------
  108. //------------------------------- End of File --------------------------------
  109. //----------------------------------------------------------------------------
  110.